//
//  LoginViewModel.m
//  iOSBaseFramework
//
//  Created by user on 2020/6/28.
//  Copyright © 2020 com.taylor. All rights reserved.
//

#import "LoginViewModel.h"

#import "TRRequestTool.h"

@implementation LoginViewModel


-(instancetype)init{
    if (self = [super init]) {
        _loginModel = [[LoginModel alloc] init];
    }
    return self;
}


-(void)requestSMSVerifyCodeWithPhoneNum:(NSString *)phoneNum AreaCode:(NSString*)areaCode Complete:(VerifyComplete)verifyComplete
{
    
    _loginModel.phoneNumString = phoneNum;
    _loginModel.areaCodeString = areaCode;
    
    
    NSDictionary *dict = @{@"phoneNum": phoneNum, @"areaCode": areaCode};
    
    [[TRRequestTool shareManager] sendRequestWithAPI:@"verify" withVC:nil withParams:dict withClass:nil responseBlock:^(id  _Nonnull response, BOOL isError, NSString * _Nonnull errorMessage, NSInteger errorCode) {
        
        if (!isError) {
            self.loginModel.phoneNumString = phoneNum;
            self.loginModel.areaCodeString = areaCode;
            self.loginModel.captchaString = [response valueForKey:@"verifyCode"];
        }
        
        if (verifyComplete) {
            verifyComplete(isError, [response valueForKey:@"data"]);
        }
    }];
}



@end
